/**
 * Copyright &copy; 2016-2022 liuhangjun All rights reserved.
 */
package com.channelsharing.hongqu.portal.api.service.impl;

import com.channelsharing.common.cache.CacheDuration;
import com.channelsharing.common.cache.ExpireTimeConstant;
import com.channelsharing.common.entity.Paging;
import com.channelsharing.common.service.CrudServiceImpl;
import com.channelsharing.hongqu.portal.api.constant.Constant;
import com.channelsharing.hongqu.portal.api.controller.discovery.DiscoveryResponseEntity;
import com.channelsharing.hongqu.portal.api.dao.DiscoveryDao;
import com.channelsharing.hongqu.portal.api.entity.Discovery;
import com.channelsharing.hongqu.portal.api.service.DiscoveryService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Map;

/**
 * 商品介绍内容Service
 * @author liuhangjun
 * @version 2018-06-12
 */
@CacheDuration(duration = ExpireTimeConstant.ONE_DAY)
@Service
public class DiscoveryServiceImpl extends CrudServiceImpl<DiscoveryDao, Discovery> implements DiscoveryService {

    public static final String PORTAL_CACHE_PREFIX = Constant.PORTAL_CACHE_PREFIX;

    @Cacheable(value = PORTAL_CACHE_PREFIX + "discovery", key = "#root.target.PORTAL_CACHE_PREFIX + 'discovery:id:' + #id", unless = "#result == null")
    @Override
    public Discovery findOne(Long id) {
        Discovery entity = new Discovery();
        entity.setId(id);
        Discovery discovery = super.findOne(entity);

        return discovery;
    }
    @CacheEvict(value = PORTAL_CACHE_PREFIX + "discovery", key = "#root.target.PORTAL_CACHE_PREFIX + 'discovery:id:' + #entity.id")
    @Transactional
    @Override
    public void modify(Discovery entity){
        super.modify(entity);
    }
}
